package demo1;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

public class Collection1 {

    public static void main(String[] args) {
//        List<String> list = Arrays.asList("ab", "c"); //不能用，固定长度的list
        ArrayList<String> list1 = new ArrayList<>();
        list1.add("a");
        list1.add("b");
        list1.add("apple");
        list1.add("watermelon");
        System.out.println(list1);
        list1.removeIf((i)->{
            return i.equals("a");
        });
        System.out.println(list1);
        //replaceAll传进入和传出来的类型需要一致，list1是string数组，接收函数是字符串，所以String::toUpperCase可以当参数
        list1.replaceAll(String::toUpperCase);




        Dog dog = new Dog();
        list1.replaceAll(dog::sayName);
//        list1.replaceAll((s)->{
//            return "aa";
//        });
        System.out.println(list1);



    }
}

final class Dog{

    public String sayName(String name){
        return "my name is"+name;
    }

}

